import { addToAnimationPool } from "@/decorators/addToAnimationPool.decorator";
import { MyThings } from "@/interfaces/myThings.interface";
import { BoxGeometry, Mesh, MeshLambertMaterial } from "three";

class MyCube implements MyThings {
  mesh: Mesh;
  loaded: Promise<void>;
  constructor() {
    this.mesh = new Mesh();
    this.mesh.name = "cube";
    this.loaded = this.init();
  }
  @addToAnimationPool()
  async init() {
    this.mesh.geometry = new BoxGeometry(50, 50, 50, 10, 10, 10);
    this.mesh.material = new MeshLambertMaterial({
      color: 0xffffff,
    });
    this.mesh.position.set(140, 90, 0);
    this.mesh.castShadow = true;
    this.mesh.receiveShadow = true;
  }
  update() {
    this.mesh.rotation.x += 0.005;
    this.mesh.rotation.y += 0.01;
  }
}

const cube = new MyCube();
export { cube };
